package javamail;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class CommonEmailTest {

	public static void main(String[] args)       
    {       
        send();       
    }       
           
    public static void send()       
    {       
        SimpleEmail email = new SimpleEmail();          
        email.setTLS(true);               
        email.setHostName("smtp.126.com");             
        email.setAuthentication("ksfzhaohui@126.com", "11111111");   //用户名和密码       
               
        try        
        {       
            email.addTo("878774263@qq.com"); //接收方       
            email.setFrom("ksfzhaohui@126.com");       //发送方         
            email.setSubject("Java Mail Test");        //标题        

            email.setCharset("GB2312");                //设置Charset 
            
            email.setMsg("Just a simple send test ."); //内容          
            email.send();        
                   
        } catch (EmailException e) {       
            e.printStackTrace();       
        }        
    }       

}
